package aom.ju.ss.view.dialog

import android.app.Activity
import androidx.core.content.ContextCompat
import aom.ju.ss.R
import aom.ju.ss.databinding.AddGoodsDialogBinding


/**
 * 选择 添加的商品类型
 */
class AddGoodsDialog(activity: Activity, var call: AddGoodsDialogCall) : BaseDialog(activity) {
    private lateinit var binding: AddGoodsDialogBinding

    init {
        setWidth(-1)
    }

    override fun isBottom(): Boolean {
        return true
    }

    override fun init() {
        binding = vBinding as AddGoodsDialogBinding
        binding.p = 1
        binding.ordinary.setOnClickListener {
            binding.p = 1
            binding.ok.performClick()
        }
        binding.cut.setOnClickListener {

            binding.p = 2
            binding.ok.performClick()
        }
        binding.dicker.setOnClickListener {
            binding.p = 4
            binding.ok.performClick()
        }
//        binding.act.setOnClickListener {
//            binding.p = 3
//            binding.ok.performClick()
//        }
//        binding.ticket.setOnClickListener {
//            binding.p = 4
//            binding.ok.performClick()
//        }
        binding.ok.setOnClickListener {
            call.call(binding.p)
            dis()
        }
        dialog.setCanceledOnTouchOutside(false)
        dialog.setCancelable(false)
    }

    override fun getLay(): Int {
        return R.layout.add_goods_dialog
    }

}

interface AddGoodsDialogCall {
    /**
     *  0 普通 1 砍价 2 易货 3活动 4 抢券
     */
    fun call(p: Int)// 0 普通 1 砍价 2 易货 3活动 4 抢券

}